<div class="crumb-wrap">
    <div class="crumb-list"> <i class="icon-font"></i>
        <a href="/jscss/admin">首页</a>
        <span class="crumb-step">&gt;</span>
        <span class="crumb-name">文章管理</span>
    </div>
</div>
<div class="search-wrap">
    <div class="search-content">
        <form action="<?=site_url('article/index')?>" method="get">
            <table class="search-tab">
                <tr>
                    <th width="120">选择分类:</th>
                    <td>
                        <select name="search-sort" id="">
                            <option value="">全部</option>
                            <?php foreach($list_sort as $k => $v):?>
                            <?php if(!empty($_GET['search-sort']) && $_GET['search-sort'] == $v['id']):?>
                                <option value="<?=$v['id']?>" selected><?=$v['title']?></option>
                            <?php else:?>
                                <option value="<?=$v['id']?>" ><?=$v['title']?></option>
                            <?php endif;?>
                            <?php endforeach;?>
                        </select>
                    </td>
                    <th width="70">关键字:</th>
                    <td>
                        <input class="common-text" placeholder="输入标题关键字查询" name="keywords" value="<?=empty($_GET['keywords']) ? '' : $_GET['keywords'];?>" id="" type="text"></td>
                    <td>
                        <input class="btn btn-primary btn2" value="查询" type="submit">
                    </td>
                    <td>
                        <a class="btn btn-primary btn2" onclick="location.href='<?=site_url('article/index')?>'">重置</a>
                    </td>
                </tr>
            </table>
        </form>
    </div>
</div>
<div class="result-wrap">
    <form name="myform" id="myform" method="post">
        <div class="result-title">
            <div class="result-list">
                <a href="<?=site_url('article/create')?>"> <i class="icon-font"></i>
                    新增文档
                </a>
            </div>
        </div>
        <div class="result-content">
            <table class="result-tab" width="100%">
                <tr>
                    <th>ID</th>
                    <th>分类</th>
                    <th>标题</th>
                    <th>点击</th>
                    <th>发布人</th>
                    <th>更新时间</th>
                    <th>操作</th>
                </tr>
                <?php foreach($list as $k => $v):?>
                <tr>
                    <td><?=$v['id']?></td>
                    <?php if(empty($v['_sort']['title'])):?>
                        <td>其他分类</td>
                    <?php else:?>
                        <td><?=$v['_sort']['title']?></td>
                    <?php endif;?>
                    <td title="<?=$v['title']?>">
                        <a href="javascript:;" onclick="open_view('<?=site_url('article/show?aid='.$v['id'])?>')" title="<?=$v['title']?>"><?=$v['title']?></a>
                    </td>
                    <td><?=$v['click']?></td>
                    <td><?=$v['username']?></td>
                    <td><?=date('Y-m-d H:i:s',$v['set_time'])?></td>
                    <td>
                        <a class="link-update" href="<?=site_url('article/update?aid='.$v['id'])?>">修改</a>
                        <a class="link-del" href="javascript:;" onclick="article_delete(<?=$v['id']?>)">删除</a>
                    </td>
                </tr>
                <?php endforeach;?>
            </table>
            <div class="list-page"><?=$page ?></div>
        </div>
    </form>
</div>
<script type="text/javascript">
    function article_delete(aid){
        layer.confirm('删除之后不可恢复，是否确定？', {
            btn: ['确定','取消'] //按钮
        }, function(){
            $.post("<?=site_url('article/delete')?>",{aid:aid},function(data){
                if(data == 1){
                    layer.alert("操作成功！",{
                        icon:1,
                    },function(){
                        location.reload();
                    });
                }else{
                    layer.alert(data,{
                        icon:2,
                    });
                }
            });
        });
    }

    function open_view(aid){
        layer.open({
            type: 2,
            area: ['800px', '600px'],
            fix: false, //不固定
            maxmin: true,
            content: aid
        });
    }
</script>